Skip to content

feat(loops): Run a skill instead of instructions#3741

Open
charlesvien wants to merge 5 commits into
mainfrom
feat/loop-skills
Open

feat(loops): Run a skill instead of instructions#3741
charlesvien wants to merge 5 commits into
mainfrom
feat/loop-skills

Conversation

@charlesvien

Copy link
Copy Markdown
Member

Problem

A loop's prompt is a free-form instructions blob. Teams that already maintain skills have no way to point a loop at one, so the same playbook gets pasted into instructions and drifts from the skill.

Changes

The loop form's prompt step gains a source choice: write instructions or run a skill. Picking a local skill zips it (plus its skill dependencies) via workspace-server on save and uploads the set through the new PUT /loops/{id}/skill_bundles/ endpoint, and the loop's instructions become /skill-name plus an optional context field. The backend seeds those bundles into every fired run, where the sandbox agent-server already installs skill_bundle artifacts.

The loop detail page shows the attached skill with its snapshot digest and an "Update from local skill" button to re-snapshot after editing the skill. On hosts without a local filesystem (web) the picker is hidden; an attached skill can still be kept or detached.

Requires PostHog/posthog#73069 to be deployed first; until then the skill_bundles endpoint 404s and loop.skill_bundles is absent.

How did you test this?

Unit tests for the new instruction build/parse helpers and the form round-trip (skill mode validity, derived instructions, attached-snapshot mapping) via pnpm --filter @posthog/ui test. Full pnpm typecheck and Biome lint are clean. Not exercised against a live backend since the API only exists in the paired posthog PR.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@trunk-io

trunk-io Bot commented Jul 23, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 1d0f2a9.

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
packages/ui/src/features/loops/components/LoopDetailView.tsx:325
**Missing bundles crash loop views**

When the older backend described in this PR omits `skill_bundles`, this unconditional `.length` access throws during rendering. The edit path also indexes the absent field in `primaryLoopSkillBundle`, so users cannot view or edit loops until the backend deployment completes.

### Issue 2 of 2
packages/ui/src/features/loops/components/LoopForm.tsx:145-153
**Failed uploads leave incomplete loops**

When dependency resolution, local bundling, or bundle upload fails, the loop has already been persisted with `/skill-name` instructions, and this catch only shows a toast before navigating away. The loop can then fire without the matching skill artifact, causing the run to receive the invocation without the selected skill definition.

Reviews (1): Last reviewed commit: "let loops run a skill instead of instruc..." | Re-trigger Greptile

Comment thread packages/ui/src/features/loops/components/LoopDetailView.tsx Outdated
@veria-ai

veria-ai Bot commented Jul 23, 2026

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 3 · PR risk: 0/10

Comment thread packages/ui/src/features/loops/components/LoopDetailView.tsx Outdated
Comment thread packages/ui/src/features/loops/components/LoopForm.tsx Outdated
Comment thread packages/ui/src/features/loops/hooks/useLoopSkillBundles.ts
Comment thread packages/ui/src/features/loops/hooks/useLoopSkillBundles.ts
@posthog

posthog Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

👋 Visual changes detected for this PR.

Review and approve in PostHog Visual Review

If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants